#ifndef IMAGE_H_
#define IMAGE_H_


#include <iostream>

class Image{


public:

	Image(int w, int h, int d=1);
	~Image();

	// creators
	static Image* createGauss();
	static Image* createHeightMap(int w, int h, int res);
	static Image* createPermutationMap();

	// operations
	void convolve(Image &filter);


	// operators
	float& set(int x, int y, int c = 1);
	float operator() (float x, float y, int c = 1) const;

	float operator[](int i) const { return data[i]; }
	float &operator[](int i) { return data[i]; }

	friend std::ostream &operator<<(std::ostream &str, const Image &m){

		for(int j=0;j<m.h;++j){
			for(int i=0;i<m.w;++i){
				for(int k=0;k<m.d;++k){

					str << m[m.getPos(j,i,k)] << " ";
				}

				str << "," << std::endl;
			}

			str << std::endl;
		}
		return str;
	}

	float *getData(){
		return data;
	}

	// lazy
	int w, h, d;

private:

	int getPos(int x, int y, int c = 1) const;


	float *data;


};


#endif /* IMAGE_H_ */
